/**
* Copyright @ 2023 iAuto (Shanghai) Co., Ltd.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are NOT permitted except as agreed by
* iAuto (Shanghai) Co., Ltd.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/


import request from '@/utils/request';
import {
  NewBaseApiResponse,
  IResponseList,
  Methods
} from '@/types/type';
import {
  abilityPushlist,
  offList,
} from '@/types/ability';


// 能力列表
export async function getAbilityList(payload: any) {
  return request<IResponseList>(`/api/ms-soa-skill/v1/admin/skill/list`, {
    method: Methods.GET,
    params: payload,
  });
}
// 获取车系
export async function getModelList() {
  return request<NewBaseApiResponse>(`/api/ms-soa-vehicle/v2/admin/model/list`, {
    method: Methods.GET,
  });
}

//   能力详情
export async function getAbilityDetail(payload: any) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/skill/detail`, {
    method: Methods.GET,
    params: payload,
  });
}

// 能力发布
export async function publishAbility(payload: abilityPushlist) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/carmodel/soc/publish`, {
    method: Methods.POST,
    data: payload,
  });
}

// 清空未发布的能力
export async function delThisAbility(payload: any) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/skill/del`, {
    method: Methods.POST,
    data: payload,
  });
}

// 退回
export async function backAbility(payload: any) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/carmodel/soc/sendBack`, {
    method: Methods.POST,
    data: payload,
  });
}

// 清空能力列表
export async function abilitySocDel(payload: any) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/carmodel/soc/del`, {
    method: Methods.POST,
    data: payload,
  });
}
// 导入
export async function abilityImport(payload: any) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/skill/importExcel`, {
    method: Methods.POST,
    data: payload,
    timeout: undefined
  });
}
// 能力导入版本检查
export async function importExcelCheck(payload: any) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/skill/importExcelCheck`, {
    method: Methods.POST,
    data: payload,
    timeout: undefined
  });
}
// 导出
export async function exportExcel(payload: any) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/skill/exportExcel`, {
    method: Methods.GET,
    params: payload,
  });
}
//  下架
export async function offShelf(payload: offList) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/carmodel/soc/offShelf`, {
    method: Methods.POST,
    data: payload,
  });
}
// 获取未发布的能力车型车系
export async function getAbilityPublishDetail() {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/skill/publish/detail`, {
    method: Methods.GET,
  });
}

// 获取soc列表
export async function getAbilityVersionList(payload: any) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/carmodel/soc/list`, {
    method: Methods.GET,
    params: payload,
  });
}

// 状态记录
export async function getStatusList(payload: any) {
  return request<IResponseList>(`/api/ms-soa-skill/v1/admin/carmodel/soc/statusRecordList`, {
    method: Methods.GET,
    params: payload,
  });
}

// 获取最新soc版本号
export async function getLastVersion(payload: any) {
  return request<NewBaseApiResponse>(`/api/ms-soa-skill/v1/admin/skill/getLastVersion`, {
    method: Methods.GET,
    params: payload,
  });
}

// 获取车系下已发布的版本和车型(能力导入时前端调用)
// http://iauto-yapi.ci.iauto.com/project/43/interface/api/10001
export async function getPublishList(payload: { sCode: string }) {
  return request<NewBaseApiResponse>(`/api/ms-soa-service/v1/admin/carmodel/soc/series/publishList`, {
    method: Methods.GET,
    params: payload,
  });
}
